﻿using System.Collections.Generic;
using System.Linq;
using Renci.iRods.Common;

namespace Renci.iRods.Packets
{
    //#define KeyValPair_PI "int ssLen; str *keyWord[ssLen]; str *svalue[ssLen];" 
    [Packet("KeyValPair_PI")]
    internal class KeyValuePairPacket : Packet
    {
        [PacketField("ssLen", 0, DataTypes.Int)]
        public int Length { get; private set; }

        [PacketField("keyWord", 1, DataTypes.String, true)]
        public string[] Key { get; private set; }

        [PacketField("svalue", 2, DataTypes.String, true)]
        public string[] Value { get; private set; }

        public KeyValuePairPacket(IDictionary<string, string> keyValue)
        {
            this.Length = keyValue.Count;
            this.Key = keyValue.Keys.ToArray();
            this.Value = keyValue.Values.ToArray();
        }

    }
}
